<template>
  <div class="app-container">
    <el-switch
      v-if="value !== null"
      v-model="value"
      @change="setConfig"
      active-text="开启商城展示"
      inactive-text="关闭商城展示">
    </el-switch>
  </div>
</template>
<script>
import { getConfig,setConfig } from '@/api/displayConfig'
export default {
  data() {
    return {
      value: null
    }
  },
  created() {
    this.getConfig()
  },
  methods: {
    setConfig() {
      console.log(this.value)
      setConfig(this.value).then(response => {
        if (response.code === 200) {
          this.$message({
            message: '设置成功',
            type: 'success'
          })
          this.getConfig()
        }
      })
    },
    getConfig() {
      getConfig().then(response => {
        console.log(response)
        this.value = response.data
      })
    }
  }
}
</script>

